namespace Webinator
{
    using System;
    using Enums;
    using Impls;
    using MultipleAttribute;
    using Toolboxes;

    /// <summary>
    /// Creates <c>Locator</c> objects.
    /// </summary>
    public static class LocateBy
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="definedAttributes">The attribute(s) to use when locating the element(s).</param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Attributes(DefinedAttributes definedAttributes)
        {
            return new Locator(FindBy.XPath, XPathToolbox.GetXpathFromDefinedAttributes(definedAttributes));
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="definedAttributes">The attribute(s) to use when locating the element(s).</param>
        /// <param name="use">Indicates which elements to use if a collection is found.</param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Attributes(DefinedAttributes definedAttributes, Use use)
        {
            return new Locator(FindBy.XPath, XPathToolbox.GetXpathFromDefinedAttributes(definedAttributes), use);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="definedAttributes">The attribute(s) to use when locating the element(s).</param>
        /// <param name="index">The index.</param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Attributes(DefinedAttributes definedAttributes, int index)
        {
            return new Locator(FindBy.XPath, XPathToolbox.GetXpathFromDefinedAttributes(definedAttributes), index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="definedAttributes">The attribute(s) to use when locating the element(s).</param>
        /// <param name="use">Indicates which elements to use if a collection is found.</param>
        /// <param name="index">The index.</param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Attributes(DefinedAttributes definedAttributes, Use use, int index)
        {
            return new Locator(FindBy.XPath, XPathToolbox.GetXpathFromDefinedAttributes(definedAttributes), use, index);
        }
        
        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="selector">
        /// The selected type.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Checkbox(Selector selector)
        {
            return GetSelectedTypeXpath(Xpath("//input[@type='checkbox']"), selector.SelectorIs, selector.Argument);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="selector">
        /// The selected type.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Radio(Selector selector)
        {
            return GetSelectedTypeXpath(Xpath("//input[@type='radio']"), selector.SelectorIs, selector.Argument);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator AllRadios()
        {
            var all = Xpath("//input[@type='radio']");
            all.Use = Use.All;
            return all;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator AllCheckboxes()
        {
            var all = Xpath("//input[@type='checkbox']");
            all.Use = Use.All;
            return all;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Xpath(Use use, string value, int index)
        {
            return new Locator(FindBy.XPath, value, use, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Xpath(Use use, string value)
        {
            return new Locator(FindBy.XPath, value, use);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Xpath(string value, int index)
        {
            return new Locator(FindBy.XPath, value, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Xpath(string value)
        {
            return new Locator(FindBy.XPath, value);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Name(Use use, string value, bool isPartial, int index)
        {
            return new Locator(FindBy.Name, value, use, isPartial, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Name(Use use, string value, bool isPartial)
        {
            return new Locator(FindBy.Name, value, use, isPartial);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Name(Use use, string value, int index)
        {
            return new Locator(FindBy.Name, value, use, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Name(Use use, string value)
        {
            return new Locator(FindBy.Name, value, use);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Name(string value, bool isPartial, int index)
        {
            return new Locator(FindBy.Name, value, isPartial, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Name(string value, int index)
        {
            return new Locator(FindBy.Name, value, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Name(string value, bool isPartial)
        {
            return new Locator(FindBy.Name, value, isPartial);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Name(string value)
        {
            return new Locator(FindBy.Name, value);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Id(Use use, string value, bool isPartial, int index)
        {
            return new Locator(FindBy.Id, value, use, isPartial, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Id(Use use, string value, bool isPartial)
        {
            return new Locator(FindBy.Id, value, use, isPartial);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Id(Use use, string value, int index)
        {
            return new Locator(FindBy.Id, value, use, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Id(Use use, string value)
        {
            return new Locator(FindBy.Id, value, use);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Id(string value, bool isPartial, int index)
        {
            return new Locator(FindBy.Id, value, isPartial, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Id(string value, int index)
        {
            return new Locator(FindBy.Id, value, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Id(string value, bool isPartial)
        {
            return new Locator(FindBy.Id, value, isPartial);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Id(string value)
        {
            return new Locator(FindBy.Id, value);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Text(Use use, string value, bool isPartial, int index)
        {
            return new Locator(FindBy.Text, value, use, isPartial, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Text(Use use, string value, bool isPartial)
        {
            return new Locator(FindBy.Text, value, use, isPartial);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Text(Use use, string value, int index)
        {
            return new Locator(FindBy.Text, value, use, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Text(Use use, string value)
        {
            return new Locator(FindBy.Text, value, use);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Text(string value, bool isPartial, int index)
        {
            return new Locator(FindBy.Text, value, isPartial, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Text(string value, int index)
        {
            return new Locator(FindBy.Text, value, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Text(string value, bool isPartial)
        {
            return new Locator(FindBy.Text, value, isPartial);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Text(string value)
        {
            return new Locator(FindBy.Text, value);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Href(Use use, string value, bool isPartial, int index)
        {
            return new Locator(FindBy.Href, value, use, isPartial, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Href(Use use, string value, bool isPartial)
        {
            return new Locator(FindBy.Href, value, use, isPartial);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Href(Use use, string value, int index)
        {
            return new Locator(FindBy.Href, value, use, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Href(Use use, string value)
        {
            return new Locator(FindBy.Href, value, use);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Href(string value, bool isPartial, int index)
        {
            return new Locator(FindBy.Href, value, isPartial, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Href(string value, int index)
        {
            return new Locator(FindBy.Href, value, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Href(string value, bool isPartial)
        {
            return new Locator(FindBy.Href, value, isPartial);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Href(string value)
        {
            return new Locator(FindBy.Href, value);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Class(Use use, string value, bool isPartial, int index)
        {
            return new Locator(FindBy.Class, value, use, isPartial, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Class(Use use, string value, bool isPartial)
        {
            return new Locator(FindBy.Class, value, use, isPartial);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Class(Use use, string value, int index)
        {
            return new Locator(FindBy.Class, value, use, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Class(Use use, string value)
        {
            return new Locator(FindBy.Class, value, use);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Class(string value, bool isPartial, int index)
        {
            return new Locator(FindBy.Class, value, isPartial, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Class(string value, int index)
        {
            return new Locator(FindBy.Class, value, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Class(string value, bool isPartial)
        {
            return new Locator(FindBy.Class, value, isPartial);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Class(string value)
        {
            return new Locator(FindBy.Class, value);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Alt(Use use, string value, bool isPartial, int index)
        {
            return new Locator(FindBy.Alt, value, use, isPartial, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Alt(Use use, string value, bool isPartial)
        {
            return new Locator(FindBy.Alt, value, use, isPartial);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Alt(Use use, string value, int index)
        {
            return new Locator(FindBy.Alt, value, use, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Alt(Use use, string value)
        {
            return new Locator(FindBy.Alt, value, use);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Alt(string value, bool isPartial, int index)
        {
            return new Locator(FindBy.Alt, value, isPartial, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Alt(string value, int index)
        {
            return new Locator(FindBy.Alt, value, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Alt(string value, bool isPartial)
        {
            return new Locator(FindBy.Alt, value, isPartial);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Alt(string value)
        {
            return new Locator(FindBy.Alt, value);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Value(Use use, string value, bool isPartial, int index)
        {
            return new Locator(FindBy.Value, value, use, isPartial, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Value(Use use, string value, bool isPartial)
        {
            return new Locator(FindBy.Value, value, use, isPartial);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Value(Use use, string value, int index)
        {
            return new Locator(FindBy.Value, value, use, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Value(Use use, string value)
        {
            return new Locator(FindBy.Value, value, use);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Value(string value, bool isPartial, int index)
        {
            return new Locator(FindBy.Value, value, isPartial, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Value(string value, int index)
        {
            return new Locator(FindBy.Value, value, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="isPartial">
        /// Indicates whether <c>Value</c> is partial.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Value(string value, bool isPartial)
        {
            return new Locator(FindBy.Value, value, isPartial);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Value(string value)
        {
            return new Locator(FindBy.Value, value);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Css(Use use, string value, int index)
        {
            return new Locator(FindBy.Css, value, use, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="use">
        /// Indicates which elements to use if a collection is found.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Css(Use use, string value)
        {
            return new Locator(FindBy.Css, value, use);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Css(string value, int index)
        {
            return new Locator(FindBy.Css, value, index);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Locator"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        public static Locator Css(string value)
        {
            return new Locator(FindBy.Css, value);
        }

        /////// <summary>
        /////// Initializes a new instance of the <see cref="Locator"/> class.
        /////// </summary>
        /////// <param name="fileName">
        /////// The image file.
        /////// </param>
        /////// <returns>
        /////// A <c>Locator</c> object.
        /////// </returns>
        ////public static Locator Image(string fileName)
        ////{
        ////    return new Locator(FindBy.Image, fileName);
        ////}

        /////// <summary>
        /////// Initializes a new instance of the <see cref="Locator"/> class.
        /////// </summary>
        /////// <param name="fileName">
        /////// The image file.
        /////// </param>
        /////// <param name="index">
        /////// The index.
        /////// </param>
        /////// <returns>
        /////// A <c>Locator</c> object.
        /////// </returns>
        ////public static Locator Image(string fileName, int index)
        ////{
        ////    return new Locator(FindBy.Image, fileName);
        ////}

        /////// <summary>
        /////// Initializes a new instance of the <see cref="Locator"/> class.
        /////// </summary>
        /////// <param name="use">
        /////// Indicates which elements to use if a collection is found.
        /////// </param>
        /////// <param name="fileName">
        /////// The image file.
        /////// </param>
        /////// <returns>
        /////// A <c>Locator</c> object.
        /////// </returns>
        ////public static Locator Image(Use use, string fileName)
        ////{
        ////    return new Locator(FindBy.Image, fileName);
        ////}

        /////// <summary>
        /////// Initializes a new instance of the <see cref="Locator"/> class.
        /////// </summary>
        /////// <param name="use">
        /////// Indicates which elements to use if a collection is found.
        /////// </param>
        /////// <param name="fileName">
        /////// The image file.
        /////// </param>
        /////// <param name="index">
        /////// The index.
        /////// </param>
        /////// <returns>
        /////// A <c>Locator</c> object.
        /////// </returns>
        ////public static Locator Image(Use use, string fileName, int index)
        ////{
        ////    return new Locator(FindBy.Image, fileName);
        ////}

        /// <summary>
        /// Creates a locator that identifies an element.
        /// </summary>
        /// <param name="locator">
        /// The locator.
        /// </param>
        /// <param name="selectBy">
        /// The selected type.
        /// </param>
        /// <param name="argument">
        /// The argument.
        /// </param>
        /// <returns>
        /// A <c>Locator</c> object.
        /// </returns>
        /// <exception cref="ArgumentOutOfRangeException">
        /// Not implemented.
        /// </exception>
        private static Locator GetSelectedTypeXpath(Locator locator, SelectorIs selectBy, string argument)
        {
            Locator returnValue;
            switch (selectBy)
            {
                case SelectorIs.Text:
                    returnValue = new Locator(FindBy.XPath, string.Format("({0})/parent::*[normalize-space(text())={1}]//input", XPathToolbox.GetXpathFromLocator(locator), XPathToolbox.XPathLiteral(argument)));
                    break;
                case SelectorIs.PartialText:
                    returnValue = new Locator(FindBy.XPath, string.Format("({0})/parent::*[contains(normalize-space(text()),{1})]//input", XPathToolbox.GetXpathFromLocator(locator), XPathToolbox.XPathLiteral(argument)));
                    break;
                case SelectorIs.Value:
                    returnValue = new Locator(FindBy.XPath, string.Format("{0}[@value='{1}']", XPathToolbox.GetXpathFromLocator(locator), XPathToolbox.XPathLiteral(argument)));
                    break;
                case SelectorIs.PartialValue:
                    returnValue = new Locator(FindBy.XPath, string.Format("{0}[contains(@value,{1})]", XPathToolbox.GetXpathFromLocator(locator), XPathToolbox.XPathLiteral(argument)));
                    break;
                case SelectorIs.Index:
                    returnValue = new Locator(FindBy.XPath, string.Format("({0})[{1}]", XPathToolbox.GetXpathFromLocator(locator), int.Parse(argument) + 1));
                    break;
                default:
                    throw new ArgumentOutOfRangeException(string.Format("SetSelectedType [{0}] not implemented.", selectBy));
            }

            return returnValue;
        }
    }
}
